home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cgraphix / dp.asm < prev    next >
Assembly Source File  |  1986-04-30  |  1KB  |  83 lines

  1.     Title - DP - assembler implementation of GRAPHIX routine
  2.  
  3.     include    model.h
  4.     include    prologue.h
  5. @CODE    ends
  6.  
  7. @DATAI    SEGMENT
  8.  
  9.     extrn    ColorGlb:word
  10.     extrn    GrafBase:word
  11.  
  12. __mask    db    07Fh, 0BFh, 0DFh, 0EFh, 0F7h, 0FBh, 0FDh, 0FEh
  13.  
  14. @DATAI    ENDS
  15.  
  16.  
  17. @CODE    SEGMENT
  18.  
  19.  
  20.     public    DP
  21.  
  22.  
  23. DPX    equ    @ab[bp]
  24. DPY    equ    @ab+2[bp]
  25.  
  26.  
  27. DP    proc    near
  28.  
  29.     push    bp            ;standard setup
  30.     mov    bp,sp
  31.  
  32. ;compute offset of start of row
  33.  
  34.     mov    ax,DPY            ;get the row
  35.     mov    ah,al            ;duplicate in high register
  36.     and    ax,01FEh        ;mask out unwanted portions
  37.                     ;  NB:    AH = row mod 2
  38.                     ;    AL = 2 * (row\2)
  39.     sal    ax,1            ;*4
  40.     sal    ax,1            ;*8
  41.     sal    ax,1            ;*16
  42.     mov    bx,ax
  43.     and    bh,7
  44.     sal    ax,1            ;*32
  45.     sal    ax,1            ;*64
  46.     add    ax,bx
  47.     mov    di,ax
  48.  
  49. ;add offset of start of column and set ES to point to video
  50.  
  51.     mov    ax,DPX            ;get column number
  52.     mov    bx,ax            ;duplicate column number
  53.     sar    ax,1            ;/2
  54.     sar    ax,1            ;/4
  55.     sar    ax,1            ;/8
  56.     add    di,ax            ;add to offset
  57.     mov    ax,GrafBase        ;set segment register of video map
  58.     mov    es,ax            ;  memory
  59.  
  60. ;get mask to desired pixel and mask of pixel to insert
  61.  
  62.     and    bx,7            ;col mod 8
  63.     mov    al,__mask[bx]        ;mask to isolate pixel
  64.     mov    bl,al            ;and construct mask to insert
  65.     not    bl            ;  pixel with colour of
  66.     and    bx,ColorGlb        ;  ColorGlb
  67.  
  68. ;set pixel
  69.  
  70.     and    al,byte ptr es:[di]    ;get and mask out pixel
  71.     or    al,bl            ;insert new pixel
  72.     mov    byte ptr es:[di],al    ;and store back into the video map
  73.  
  74.     pop    bp            ;standard return
  75.     ret
  76.  
  77. DP    endp
  78.  
  79.     include    epilogue.h
  80.  
  81.     end
  82.  
  83.